package com.juku2024.juku.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.tools.AppUtils

class TubeEpisodeListAdapter(var episodes: ArrayList<String>) : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_episode_album, episodes) {

    // 是否有解锁广告
    var isAlbum: Boolean = false
    var currentPos = 0

    override fun convert(holder: BaseViewHolder, item: String) {
        val tvEpisode = holder.getView<TextView>(R.id.tv_episode)
        tvEpisode.text = item
        tvEpisode.setBackgroundResource(R.drawable.shape_episode)
        tvEpisode.setTextColor(AppUtils.getColor(R.color.c333333))
        holder.itemView.alpha = 1f
        tvEpisode.textSize = if (isAlbum) {
            16f
        } else {
            12f
        }

        if (currentPos == holder.layoutPosition) {
            tvEpisode.setBackgroundResource(R.drawable.shape_episode_seleteted)
            tvEpisode.setTextColor(AppUtils.getColor(R.color.teal_900))
            holder.itemView.alpha = 0.8f
        } else {
            tvEpisode.setBackgroundResource(R.drawable.shape_episode)
            tvEpisode.setTextColor(AppUtils.getColor(R.color.c333333))
            holder.itemView.alpha = 1f
        }
    }
}